package com.onlineMIS.ORM.DAO.headQ.inventoryFlow;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.onlineMIS.ORM.DAO.BaseDAO;
import com.onlineMIS.ORM.entity.headQ.inventoryFlow.HeadQInventoryStore;
import com.onlineMIS.ORM.entity.headQ.inventoryFlow.HeadqInventoryFlowOrder;
import com.onlineMIS.ORM.entity.chainS.inventoryFlow.ChainInventoryFlowOrder;
import com.onlineMIS.ORM.entity.headQ.inventory.InventoryOrder;
import com.onlineMIS.ORM.entity.headQ.inventory.InventoryOrderProduct;
import com.onlineMIS.common.loggerLocal;

@Repository
public class HeadQInventoryFlowOrderDAOImpl extends BaseDAO<HeadqInventoryFlowOrder> {

	public HeadqInventoryFlowOrder selectOrderById(String id) {
		DetachedCriteria criteria = DetachedCriteria.forClass(HeadqInventoryFlowOrder.class);				
		criteria.add(Restrictions.eq("id", Integer.valueOf(id)));			
		criteria.add(Restrictions.eq("status", HeadqInventoryFlowOrder.STATUS_DRAFT));	
		//备注单据或者是库存单据草稿
		criteria.add(Restrictions.or(Restrictions.eq("type", HeadqInventoryFlowOrder.INVENTORY_ORDER), Restrictions.eq("type", HeadqInventoryFlowOrder.INVENTORY_DRAFT)));
		List<HeadqInventoryFlowOrder> list = this.getByCritera(criteria, true);
		if (list.size() != 0) {
			return list.get(0);
		}
		return null;
	}

		public HeadqInventoryFlowOrder retrieveOrder(int order_ID) {
		HeadqInventoryFlowOrder order =null;

        order = get(order_ID, false);
        
        if (order != null)
            initialize(order);

		return order;
	}


}
